﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using CarolLib;

namespace DBUtility
{
    public class SqlHelperCarol
    {
        public static string connectionString = System.Configuration.ConfigurationSettings.AppSettings["SQLconnString"].ToString();

        public static DataSet ExecuteDataSet(string strConnectionString, string SQL, SqlParameter[] Parameters)
        {
            using (SqlConnection conn = new SqlConnection(strConnectionString))
            {
                return SqlHelper.ExecuteDataSet(conn, SQL, Parameters);
            }
        }

        public static DataSet ExecuteDataSet(string SQL, SqlParameter[] Parameters)
        {
            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                return SqlHelper.ExecuteDataSet(conn, SQL, Parameters);
            }
        }

        public static DataSet ExecuteDataSet(string strConnectionString, string SQL)
        {
            List<SqlParameter> Parameters = new List<SqlParameter>();
            using (SqlConnection conn = new SqlConnection(strConnectionString))
            {
                return SqlHelper.ExecuteDataSet(conn, SQL, Parameters.ToArray());
            }
        }

        public static DataSet ExecuteDataSet(string SQL)
        {
            List<SqlParameter> Parameters = new List<SqlParameter>();
            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                return SqlHelper.ExecuteDataSet(conn, SQL, Parameters.ToArray());
            }
        }

        public static void ExecuteNonQuery(string strConnectionString, string SQL, SqlParameter[] Parameters)
        {
            using (SqlConnection conn = new SqlConnection(strConnectionString))
            {
                SqlHelper.ExecuteNonQuery(conn, SQL, Parameters);
            }
        }

        public static void ExecuteNonQuery(string SQL, SqlParameter[] Parameters)
        {
            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                SqlHelper.ExecuteNonQuery(conn, SQL, Parameters);
            }
        }

        public static void ExecuteNonQuery(string strConnectionString, string SQL)
        {
            List<SqlParameter> Parameters = new List<SqlParameter>();
            using (SqlConnection conn = new SqlConnection(strConnectionString))
            {
                SqlHelper.ExecuteNonQuery(conn, SQL, Parameters.ToArray());
            }
        }

        public static void ExecuteNonQuery(string SQL)
        {
            List<SqlParameter> Parameters = new List<SqlParameter>();
            using (SqlConnection conn = new SqlConnection(connectionString))
            {
                SqlHelper.ExecuteNonQuery(conn, SQL, Parameters.ToArray());
            }
        }
    }
}
